﻿@model List<string>
@{ 
	var Dir = Utility.Request("Dir","",false);
}
<div class="layui-card">
	<div class="layui-card-header layuiadmin-card-header-auto" style="padding-top:0px;padding-bottom:0px;">
		<span class="layui-breadcrumb">
			当前目录：@Html.Raw(ViewBag.NavText) 
		</span>
		<span style="float: right;">
			<a class="layui-btn layui-btn-xs" href="/Admin/Template/StyleManage?Dir=@ViewBag.ParentDir">返回上一层</a>
		</span>
	</div>

	<div class="layui-card-body">
		<table id="tblList" lay-filter="tblList"></table>
		<script type="text/html" id="toolbarHead">
			<div class="layui-form-item" style="margin: auto;">
				<div class="layui-inline">
					<div class="layui-input-inline">
						<select id="dropMove">
							<option value="">请选择目标文件夹</option>
							@foreach (var item in Model)
							{
								<option value="@item">@item</option>
							}
						</select>
					</div>
					<div class="layui-input-inline layui-input-company">
						<button class="layui-btn layuiadmin-btn-list" onclick="MoveDir()">批量移动</button>
					</div>
				</div>
				<div class="layui-inline">
					<button class="layui-btn layuiadmin-btn-list">批量删除</button>
					<button class="layui-btn layuiadmin-btn-list">新建目录</button>
					<button class="layui-btn layuiadmin-btn-list">新建风格</button>
					<button class="layui-btn layuiadmin-btn-list">上传风格</button>
				</div>
			</div>
		</script>
		<script type="text/html" id="tblTypeCol">
			{{# if(d.Type == "1"){ }}
			文件夹
			{{# } else { }}
			{{d.Content_type}}文件
			{{# } }}
		</script>
		<script type="text/html" id="tblBarCol">
			{{# if(d.Type != "1" && d.Content_type == "css"){ }}
			<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
			{{# } }}
			<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
			<button class="layui-btn layui-btn-xs" lay-event="copy"><i class="layui-icon layui-icon-file"></i>复制</button>
			<button class="layui-btn layui-btn-xs" lay-event="rename">重命名</button>
		</script>
	</div>
</div>
@Html.AntiForgeryToken()
@section scripts {
	<script type="text/javascript">
		layui.use(['form', 'table'], function () {
			var table = layui.table;
			var form = layui.form;
			var Dir = "@Dir";
			var SearchParam = { "Dir": Dir };

			var myCols = [
				{ type: "checkbox", width: 30, fixed: "left", align: 'center' },
				{ field: 'Name', minWidth: 150, title: '名称', align: 'left' },
				{ field: 'Size', width: 80, title: '大小', align: 'center' },
				{ field: 'Type', width: 80, title: '类型', align: 'center', templet: '#tblTypeCol' },
				{ field: 'LastWriteTime', width: 180, title: '最后修改时间', align: 'center', templet: function (d) { return showDateTime(d.LastWriteTime); }},
				{ field: 'ID', width: 300, title: '操作', align: "center", templet: '#tblBarCol' }
			];

			//加载表格
			table.render({
				elem: '#tblList'
				, url: '/Admin/Template/GetStyleManageList'
				, toolbar: '#toolbarHead'
				, where: SearchParam
				, request: {
					pageName: 'PageNum' //页码的参数名称，默认：page
					, limitName: 'PageSize' //每页数据量的参数名，默认：limit
				}
				, cols: [myCols]
				, parseData: function (res) { //res 即为原始返回的数据
					return {
						"code": 0, //解析接口状态
						"msg": "", //解析提示文本
						"count": res.RecordTotal, //解析数据长度
						"data": res.RowList //解析数据列表
					};
				}
				, limits: [10, 15, 20, 25, 50, 100]
				, limit: 100000
				, page: false
			});
			//监听表格头部工具栏
			table.on('toolbar(tblList)', function (obj) {
				if (obj.event === 'add') {
					
				} else if (obj.event === 'view') {
					
				} else if (obj.event === 'sort') {
					
				}
			});
			//监听表格操作列
			table.on('tool(tblList)', function (obj) {
				var dir = Dir + "/" + obj.data.Name;
				if (obj.event === 'edit') {
					layer_show('编辑风格', '/Admin/Template/StyleSheetsEdit?mAction=Modify&Dir=' + dir);
					return false;
				} else if (obj.event === 'del') {

					return false;
				} else if (obj.event === 'copy') {

					return false;
				} else if (obj.event === 'rename') {

					return false;
				}
			});

		});
	</script>
}